<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<form action="/cron/check_sales.php">
User ID<input type="text" id="uid" name="uid" value="<?php echo $_GET['uid']; ?>"><br>
Date Range:<input type="text" id="from_date" name="from_date" value="<?php echo $_GET['from_date']; ?>"> to <input type="text" id="to_date" name="to_date" value="<?php echo $_GET['to_date']; ?>"><br>
<input type='submit' name='submit' value="Check" />
</form>

<?php
set_time_limit(0);
$root=preg_replace('/cron$/', '', dirname(__FILE__));

require_once($root."inc.config.php");

require_once($root."initialize.php");

$no=0;
$uid = $_GET['uid'];
$from_date = $_GET['from_date'];
$to_date = $_GET['to_date'];
if(trim($uid)!=""){

if(($db_msg=cron_initialize()) !== true){
	print_r("Connection error");
}else{
	$sponsor_sales = @mysql_result(mysql_query("select sum(e.total_bv) from gg_users d inner join gg_users s on s.id=".$uid." and d.ref_left between s.ref_left and s.ref_right inner join gg_purchase e on e.uid=d.id and e.cdate between '".$from_date." 00:00:00' and '".$to_date." 23:59:59'"), 0);
	$placement_sales = @mysql_result(mysql_query("select sum(e.total_bv) from gg_users d inner join gg_users s on s.id=".$uid." and d.matrix_left between s.matrix_left and s.matrix_right inner join gg_purchase e on e.uid=d.id and e.cdate between '".$from_date." 00:00:00' and '".$to_date." 23:59:59'"), 0);
	
	echo "<table border=1><tr><td>User ID</td><td>Sponsor Group Sales</td><td>Placement Group Sales</td></tr>";
	echo "<tr><td>".$uid."</td><td>".number_format($sponsor_sales,0)."</td><td>".number_format($placement_sales,0)."</td></tr></table>";
}
}
exit;		
?>